//package com.zmn.plat.dubbo.impl.servcategory;
//
//import com.zmn.common.constant.GlobalConsts;
//import com.zmn.common.dto.VtDTO;
//import com.zmn.common.dto2.ResponseDTO;
//import com.zmn.common.utils.collection.CollectionUtil;
//import com.zmn.manager.common.database.annotation.ReadOnlyConnection;
//import com.zmn.plat.business.interfaces.servcategory.CategoryFaultImageBService;
//import com.zmn.plat.common.constant.BaseCodeMapConsts;
//import com.zmn.plat.common.dictionary.PlatErrorCodeDict;
//import com.zmn.plat.common.dto.base.FaultImageDRO;
//import com.zmn.plat.common.exception.PlatException;
//import com.zmn.plat.dubbo.interfaces.servcategory.CategoryFaultImageRemoteService;
//import com.zmn.plat.dubbo.utils.DubboConsts;
//import com.zmn.plat.model.entity.product.BaseCodeMap;
//import com.zmn.plat.model.entity.product.BaseCodeMapQuery;
//import com.zmn.plat.model.entity.product.ServProduct;
//import com.zmn.plat.services.interfaces.product.BaseCodeMapService;
//import com.zmn.plat.services.interfaces.product.ServProductService;
//import lombok.extern.slf4j.Slf4j;
//import org.apache.dubbo.config.annotation.Service;
//
//import javax.annotation.Resource;
//import java.util.ArrayList;
//import java.util.List;
//import java.util.Objects;
//import java.util.stream.Collectors;
//
///**
// * 描述: 后端产品分类-故障图片查询dubbo实现
// *
// * @author fengxuecai
// * @since 2021/11/26 19:16
// */
//@Slf4j
//@Service(version = DubboConsts.INTERFACE_VERSION, validation = "true")
//public class CategoryFaultImageRemoteServiceImpl implements CategoryFaultImageRemoteService {
//
//    @Resource
//    private CategoryFaultImageBService categoryFaultImageBService;
//
//    @Resource
//    private ServProductService servProductService;
//
//    @Resource
//    private BaseCodeMapService baseCodeMapService;
//
//    @Override
//    @ReadOnlyConnection
//    public ResponseDTO<FaultImageDRO> getDefaultImageByServCategIdAndCategId(Integer servCategId, Integer categId) {
//
//        log.info("CategoryFaultImageRemoteServiceImpl.getDefaultImageByServCategIdAndCategId入参：servCategId={},categId={}", servCategId, categId);
//        try {
//            FaultImageDRO faultImageMap = categoryFaultImageBService.getDefaultImageByServCategIdAndCategId(servCategId, categId);
//            return ResponseDTO.success(faultImageMap);
//        } catch (PlatException e) {
//            return ResponseDTO.fromErrorCodeTable(e.getErrorCode());
//        } catch (Exception e) {
//            log.error("CategoryFaultImageRemoteServiceImpl.getDefaultImageByServCategIdAndCategId查询失败,原因:{}", e.getMessage(), e);
//            return ResponseDTO.fail("查询失败，程序异常");
//        }
//    }
//
//    @Override
//    public ResponseDTO<FaultImageDRO> getDefaultImageByBkProductId(Integer bkProductId) {
//
//        log.info("CategoryFaultImageRemoteServiceImpl.getDefaultImageByBkProductId入参：bkProductId={}", bkProductId);
//        try {
//            ServProduct servProduct = servProductService.findByKeyWithCache(bkProductId);
//            if (Objects.isNull(servProduct)) {
//                log.error("CategoryFaultImageRemoteServiceImpl.getDefaultImageByBkProductId查询后台产品失败,bkProductId={}", bkProductId);
//                throw new PlatException(PlatErrorCodeDict.ERROR_CODE_RESULT_NULL);
//            }
//            FaultImageDRO faultImageMap = categoryFaultImageBService.getDefaultImageByServCategIdAndCategId(servProduct.getServCategId(), servProduct.getCategId());
//            return ResponseDTO.success(faultImageMap);
//        } catch (PlatException e) {
//            return ResponseDTO.fromErrorCodeTable(e.getErrorCode());
//        } catch (Exception e) {
//            log.error("CategoryFaultImageRemoteServiceImpl.getDefaultImageByServCategIdAndCategId查询失败,原因:{}", e.getMessage(), e);
//            return ResponseDTO.fail("查询失败，程序异常");
//        }
//    }
//
//    @Override
//    @ReadOnlyConnection
//    public ResponseDTO<List<FaultImageDRO>> listFaultImageByServCategIdAndCategIdAndFaultIds(Integer servCategId, Integer categId, List<Integer> faultIds) {
//
//        log.info("CategoryFaultImageRemoteServiceImpl.listFaultImageByServCategIdAndCategIdAndFaultIds入参：servCategId={},categId={},faultIds={}", servCategId, categId, faultIds);
//        try {
//            List<FaultImageDRO> faultImageMap = categoryFaultImageBService.listFaultImageByServCategIdAndCategIdAndFaultIds(servCategId, categId, faultIds);
//            return ResponseDTO.success(faultImageMap);
//        } catch (PlatException e) {
//            return ResponseDTO.fromErrorCodeTable(e.getErrorCode());
//        } catch (Exception e) {
//            log.error("CategoryFaultImageRemoteServiceImpl.listFaultImageByServCategIdAndCategIdAndFaultIds查询失败,原因:{}", e.getMessage(), e);
//            return ResponseDTO.fail("查询失败，程序异常");
//        }
//    }
//
//    @Override
//    public ResponseDTO<List<FaultImageDRO>> listFaultImageByBkProductIdAndFaultIds(Integer bkProductId, List<Integer> faultIds) {
//
//        log.info("CategoryFaultImageRemoteServiceImpl.listFaultImageByBkProductIdAndFaultIds入参：bkProductId={},faultIds={}", bkProductId, faultIds);
//        try {
//            ServProduct servProduct = servProductService.findByKeyWithCache(bkProductId);
//            if (Objects.isNull(servProduct)) {
//                log.error("CategoryFaultImageRemoteServiceImpl.listFaultImageByBkProductIdAndFaultIds查询后台产品失败,bkProductId={}", bkProductId);
//                throw new PlatException(PlatErrorCodeDict.ERROR_CODE_RESULT_NULL);
//            }
//            List<FaultImageDRO> faultImageMap = categoryFaultImageBService.listFaultImageByServCategIdAndCategIdAndFaultIds(servProduct.getServCategId(), servProduct.getCategId(), faultIds);
//            return ResponseDTO.success(faultImageMap);
//        } catch (PlatException e) {
//            return ResponseDTO.fromErrorCodeTable(e.getErrorCode());
//        } catch (Exception e) {
//            log.error("CategoryFaultImageRemoteServiceImpl.listFaultImageByBkProductIdAndFaultIds查询失败,原因:{}", e.getMessage(), e);
//            return ResponseDTO.fail("查询失败，程序异常");
//        }
//    }
//
//    @Override
//    public ResponseDTO<List<VtDTO>> baseCodeMapFaultPart() {
//        List<VtDTO> list = new ArrayList<>();
//        BaseCodeMapQuery query = new BaseCodeMapQuery();
//        query.setOneTypeId(BaseCodeMapConsts.BASE_CODE_MAP_ONE_TYPE_NUMBER_FAULT_PART);
//        query.setStatus(GlobalConsts.YES);
//        List<BaseCodeMap> baseCodeMaps = baseCodeMapService.listByQuery(query);
//        if (CollectionUtil.isNotNullOrEmpty(baseCodeMaps)) {
//            list = baseCodeMaps.stream().map(x -> new VtDTO(x.getThreeTypeId(), x.getName())).collect(Collectors.toList());
//        }
//        return ResponseDTO.success(list);
//    }
//}
